/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Sorting;

import java.awt.Font;
import javax.media.j3d.Appearance;
import javax.media.j3d.ColoringAttributes;
import javax.media.j3d.Font3D;
import javax.media.j3d.FontExtrusion;
import javax.media.j3d.Shape3D;
import javax.media.j3d.Text3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Color3f;
import javax.vecmath.Point3f;
import javax.vecmath.Vector3f;

/**
 *
 * @author rafael
 */
public class Texto {

    public TransformGroup tgTexto;
    public String frase;


    public Texto(String texto, TransformGroup tg){

        addFrase(texto);
        addTGTexto(tg);
        addText();

        tgTexto.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
        tgTexto.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        

    }

    public Texto(String[] texto, TransformGroup tg, int i){

        addFrase(texto[i]);
        addTGTexto(tg);
        addText();

        tgTexto.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
        tgTexto.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    }

    void addFrase(String f){
        frase = f;
    }

    public void addTGTexto(TransformGroup trans){
    tgTexto = trans;
    }

    public String getTexto(){
    return frase;
    }

    public TransformGroup getTGTexto(){
    return tgTexto;
    }

    public void addText() {
        
        Font3D fonte = new Font3D(new Font("Century Gothic", Font.BOLD, 1), new FontExtrusion());
        Text3D texto = new Text3D(fonte, new String(frase), new Point3f(0.0f, 0.0f, 0.0f));

        Appearance aparencia = new Appearance();

        ColoringAttributes corAP = new ColoringAttributes(new Color3f(0.1f, 0.2f, 0.3f), 1);
        aparencia.setColoringAttributes(corAP);

        Shape3D aparenciaTexto = new Shape3D(texto);

        aparenciaTexto.setAppearance(aparencia);

        Transform3D tfText = new Transform3D();
        tfText.setScale(Main.raio * 1.1 - 0.1f);

        tfText.setTranslation(new Vector3f(-Main.raio/2, -Main.raio/2, Main.raio));
        TransformGroup tgText = new TransformGroup(tfText);

        tgText.addChild(aparenciaTexto);
        tgTexto.addChild(tgText);

    }

}
